package cn.maxhou.crm.controller;


import cn.maxhou.crm.entity.Employee;
import cn.maxhou.crm.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-07-23
 */
@Controller
public class EmployeeController {
    @Autowired
    private IEmployeeService employeeService;

    @GetMapping("/employees")
    public String getList(Model model) {
        List<Employee> list = employeeService.list();
        model.addAttribute("list", list);
        return "empList";
    }
    @GetMapping("/user/{id}")
    public String getUser(@PathVariable Integer id, Model model) {
        Employee emp = employeeService.getById(id);
        model.addAttribute("emp", emp);
        return "empDetail";
    }
}
